/**
 * @author Andreas Lehner
 * @file   Crypter.h
 * @brief  Declaration of the class Crypter.
 * 
 */
#ifndef CRYPTER_H
#define CRYPTER_H

#include <string>
#include "Object.h"

/**
 * @class Crypter
 * @brief Adaptee (intern interface for Epcos and Nortel).
 * Class Crypter provides functions for reading and writing files.
 * Delegates Encrypt and Decrypt functions to its derived classes
 */
class Crypter : public Object {
public:
	/**
	 * @brief Reads a file.
	 * This function opens and reads a file and stores data in a string (mData).
	 * @param fileName The file to be read.
	 * @return A boolean value. True if reading file succeeded, false otherwise.
	 */
	bool ReadFile(std::string const& fileName);
	/**
	 * @brief Writes to a file.
	 * This function opens and writes a file. Written data is stored
	 * internally in a string (mData).
	 * @param fileName The file to be written.
	 * @return A boolean value. True if writing file succeeded, false otherwise.
	 */
	bool WriteFile(std::string const& fileName);
	/**
	 * @brief Encrypts a string with certain crypto algorithm.
	 * This function encrypts a string (stored in mData) with crypto algorithm
	 * and stores the result back to mData.
	 */
	virtual void Encrypt() = 0;
	/**
	 * @brief Decrypts a string with certain crypto algorithm.
	 * This function decrypts a string (stored in mData) with crypto algorithm
	 * and stores the result back to mData.
	 */
	virtual void Decrypt() = 0;
	/**
	 * @brief Calculates the raw filename after decrypting
	 * This function gets the raw filename of a file (it cuts the file extension
	 * of encrypted file if extension is existent)
	 * @param fileName The filename to be cut
	 * @return string consisting of filename
	 * @throws std::Exception If an error happens when filename is empty.
	 */
	virtual std::string getRawFilename(std::string const & fileName) const;
	/**
	 * @brief Calculates the output filename after encrypting
	 * This function gets the output filename of a file (it appends the file extension
	 * of decrypted file)
	 * @param fileName The filename to be extended
	 * @return string consisting of filename
	 * @throws std::Exception If an error happens when filename is empty.
	 */
	virtual std::string getOutputFilename(std::string const & fileName) const;
	/**
	 * @brief Get file extension
	 * This function gets the file extension from the corresponding crypto algorithm.
	 * The extension is provided by algorithm
	 * @return string file extension
	 */
	virtual std::string getFileExtension() const = 0;

protected:
	/**
	 * @brief string where crypted data is stored
	 * ReadFile stores read data in this variable. Holds encrypted and
	 * decrypted data.
	 */
	std::string mData;
};

#endif